package com.airwallex

import com.airwallex.util.CalculatorUtils
import com.airwallex.util.RPNCalculator
import org.junit.Rule
import org.junit.contrib.java.lang.system.SystemOutRule
import spock.lang.Specification
import spock.lang.Unroll

/**
 * Spock + groovy单元测试
 */
class CalcTest extends Specification {

//    @Rule
//    public final SystemOutRule systemOutRule =new SystemOutRule().enableLog();
//    RPNCalculator rpnCalculator;
//
//    def setup() {
//        rpnCalculator = new RPNCalculator();
//    }
//
//    def cleanup() {
//        rpnCalculator = null;
//    }
//
//    @Unroll
//    def "测试单运算符" (String expression, String expectStack) {
//        given:
//        RPNCalculator rpnCalculator = new RPNCalculator();
//        rpnCalculator.calcRPN(expression);
//        String actualStack = systemOutRule.getLog();
//
//        expect:
//        actualStack.equals(expectStack)
//
//        where:
//        expression  | expectStack
//        "+"         | "operator + (position: 1): insucient parameters\r\nstack: \r\n"
//        "-"         | "operator - (position: 1): insucient parameters\r\nstack: \r\n"
//        "*"         | "operator * (position: 1): insucient parameters\r\nstack: \r\n"
//        "/"         | "operator / (position: 1): insucient parameters\r\nstack: \r\n"
//        "clear"     | "stack: \r\n"
//        "undo"      | "stack: \r\n"
//    }
//
//    @Unroll
//    def "测试全数字" (String expression, String expectStack) {
//        given:
//        rpnCalculator.calcRPN(expression);
//        String actualStack = systemOutRule.getLog();
//
//        expect:
//        actualStack.equals(expectStack)
//
//        where:
//        expression    | expectStack
//        "5 2"         | "stack: 5 2 \r\n"
//        "5.00 2"      | "stack: 5.00 2 \r\n"
//        "5.00 2.00"   | "stack: 5.00 2.00 \r\n"
//    }
//
//    @Unroll
//    def "测试全负数" (String expression, String expectStack) {
//        given:
//        rpnCalculator.calcRPN(expression);
//        String actualStack = systemOutRule.getLog();
//
//        expect:
//        actualStack.equals(expectStack)
//
//        where:
//        expression      | expectStack
//        "-5 -2"         | "stack: -5 -2 \r\n"
//        "-5.00 -2"      | "stack: -5.00 -2 \r\n"
//        "-5.00 -2.00"   | "stack: -5.00 -2.00 \r\n"
//    }
}
